package zero.tech.games.gate.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import zero.tech.games.entity.games.ClubMemberPermission;

public interface ClubMemberPermissionMapper {

	@Insert("insert into club_member_permission(add_person,kick_club,frozen_line,frozen_person,frozen_person_gold,"
			+ "add_money,reduce_money,set_hehuoren,del_hehuoren,kick_room,create_game_rule,switch_game_rule,look_allsubs) "
			+ "values(#{add_person},#{kick_club},#{frozen_line},#{frozen_person},"
			+ "#{frozen_person_gold},#{add_money},#{reduce_money},#{set_hehuoren},#{del_hehuoren},#{kick_room},"
			+ "#{create_game_rule},#{switch_game_rule},#{look_allsubs})")
	@Options(useGeneratedKeys = true,keyProperty = "permission_id")
	void insert(ClubMemberPermission clubMemberPermission);

	@Select("select t2.* from club_member_role t1 left join club_member_permission t2 on t1.permission_id=t2.permission_id "
			+ "where t1.club_id=#{club_id} and t1.uid=#{uid}")
	ClubMemberPermission getClubMemberPermission(@Param("club_id")int club_id, @Param("uid")int uid);
	@Delete("delete from club_member_permission where permission_id=#{permission_id}")
	void deleteById(@Param("permission_id")int permission_id);

	@Update("update club_member_permission set add_person=#{add_person},add_money=#{add_money},reduce_money=#{reduce_money},"
			+ "set_hehuoren=#{set_hehuoren},del_hehuoren=#{del_hehuoren},frozen_person=#{frozen_person},frozen_line=#{frozen_line},"
			+ "frozen_person_gold=#{frozen_person_gold},create_game_rule=#{create_game_rule},switch_game_rule=#{switch_game_rule},"
			+ "kick_room=#{kick_room},kick_club=#{kick_club},look_allsubs=#{look_allsubs} where permission_id=#{permission_id}")
	void update(ClubMemberPermission clubMemberPermission);

	@Delete("delete from club_member_permission where permission_id=#{permission_id}")
	void delete(@Param("permission_id")int permission_id);

}
